package com.xiaoyu.lanling.feature.setting.activity

import android.os.Bundle
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.activity.base.AppCompatToolbarActivity
import com.xiaoyu.lanling.feature.user.data.UserInfoData
import com.xiaoyu.lanling.feature.user.model.UserExtra
import kotlinx.android.synthetic.main.setting_prize_activity.*

class SettingPrizeActivity : AppCompatToolbarActivity() {

    private val requestTag = Any()

    override fun onCreateSafelyAfterAppFinishInit(savedInstanceState: Bundle?) {
        super.onCreateSafelyAfterAppFinishInit(savedInstanceState)
        setLightStatusBar()
        setContentView(R.layout.setting_prize_activity)
        initToolbar()

        initView()
        initBind()
    }

    private fun initView() {
        title = getString(R.string.setting_prize_title)

        val checked = UserExtra.instance.baseSetting.cupidAndAccostSwitch
        prize_switch.isChecked = checked
    }

    private fun initBind() {
        prize_switch.setOnCheckedChangeListener { _, isChecked ->
            UserInfoData.setUserSetting(requestTag, isChecked)
        }
    }
}